﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HPCERP.Model;

namespace HPCERP.SetupDatabase
{
    public class CleanDatabase
    {
        hpc_erpEntities ctx = new hpc_erpEntities();

        public void Clean()
        {
            DeleteCompany();
            DeletePhrase();
        }

        private void DeletePhrase()
        {
            var phrases  = from p in ctx.Phrase select p;
            foreach (Phrase phrase in phrases)
            {
                ctx.Phrase.DeleteObject(phrase);
            }
            ctx.SaveChanges();
        }

        private void DeleteCompany()
        {
            var companies = from c in ctx.Company select c;
            foreach (Company company in companies)
            {
                ctx.Company.DeleteObject(company);
            }
            ctx.SaveChanges();
        }

    }
}
